import Vue from 'vue';
import { getUserInfo } from '@/api/login.js';
const user = {
  state: {
    userInfo: uni.getStorageSync('userInfo') || {},
    name: 'dainties-room'
  },

  mutations: {
    SET_USERINFO: (state, userInfo) => {
      state.userInfo = userInfo;
    }
  },
  actions: {
    // 获取用户信息
    setUserInfo ({ commit, state }, data) {
      // return new Promise((resolve, reject) => {
      //   getUserInfo().then((res) => {
      //     console.log("res", res);
      uni.setStorageSync('userInfo', { ...data });
      commit('SET_USERINFO', { ...data });
      //   resolve();
      // });
      // });
    }
  }
};

export default user;
